{template 'common/header'}

<div class="upgrade-content">

	<div class="upgrade-heading we7-padding-vertical text-center">

		<img src="./resource/images/logo/logo-lg.png" alt="" class="we7-logo"/>

		<h2 class="upgrade-version">系统当前版本: {IMS_FAMILY}{IMS_VERSION}（{IMS_RELEASE_DATE}）</h2>

	</div>

	{if !empty($upgrade) && !empty($upgrade['upgrade'])}

	<form action="" class="form we7-form">

		<div class="upgrade-info we7-padding-bottom">

			<div class="panel we7-panel">

				<div class="panel-heading we7-padding">

					<span class="col-sm-2 we7-padding-none color-gray">最新版本</span>

					<span class="col-sm-7 we7-padding-none">微信开放平台 {$upgrade['family']}{$upgrade['version']}【{$upgrade['release']}】版</span>

				</div>

				<div class="panel-body we7-padding">

					<div class="form-group">

						<label for="" class="control-label color-gray col-sm-2">需要更新文件</label>

						<div class="form-controls col-sm-7 form-control-static">{php echo count($upgrade['files'])} 个</div>

						<span class="color-default col-sm-3 text-right"><a href="#upgrade-file" data-toggle="modal" >查看</a></span>

					</div>

					<div class="form-group">

						<label for="" class="control-label color-gray col-sm-2">需要更新数据库</label>

						<div class="form-controls col-sm-7 form-control-static">{php echo count($upgrade['database'])} 项</div>

						<span class="color-default col-sm-3 text-right"><a href="#upgrade-databases" data-toggle="modal" >查看</a></span>

					</div>

					<div class="form-group">

						<label for="" class="control-label color-gray col-sm-2">需要更新脚本</label>

						<div class="form-controls col-sm-7 form-control-static">{php echo count($upgrade['scripts'])} 项</div>

						<span class="color-default col-sm-3 text-right"><a href="#upgrade-scripts" data-toggle="modal" >查看</a></span>

					</div>

					<div class="form-group  we7-padding-none">

						<label for="" class="control-label color-gray col-sm-2">更新协议事项</label>

						<div class="form-controls col-sm-10 form-control-static">

							<div class="">

								<input id='agreement_0' type="checkbox" name='agreement_0' autocomplete="off" />

								<label for="agreement_0">更新时请注意备份网站数据和相关数据库文件！不强制要求用户跟随官方意愿进行更新尝试！</label>

							</div>

							<div class="">

								<input id='agreement_1' type="checkbox" name='agreement_1' autocomplete="off"/>

								<label for="agreement_1">已经做好了相关文件的备份工作，认同官方的更新行为并自愿承担更新所存在的风险</label>

							</div>

							<div class="">

								<input id='agreement_2' type="checkbox" name='agreement_2' autocomplete="off"/>

								<label for="agreement_2">认同“购买系统商业授权后进行商业化运营”的协议</label>

							</div>

						</div>

					</div>

				</div>

			</div>

			<div class="alert alert-danger">

		<i class="fa fa-exclamation-triangle"></i> 更新时请注意备份网站数据和相关数据库文件！官方不强制要求用户跟随官方意愿进行更新尝试！

	</div>

			<div class="text-center">

				<input type="button" name="" id="forward" value="一键更新" class="btn btn-danger" />

				<input name="rollback" type="button" value="撤回更新" class="btn btn-default" data-toggle="modal" data-target="#rollback-panel" />

			</div>

		</div>

	</form>

	{else}

	<form action="" method="post">

		<div class="upgrade-info we7-padding-bottom">

			<div class="panel we7-panel">

				<div class="panel-heading we7-padding">

					<span class="we7-padding-none color-gray">当前版本为最新版本，您可以点击此按钮, 立即检查是否有新版本。</span>

				</div>

			</div>

	<div class="alert alert-danger">
		<i class="fa fa-exclamation-triangle"></i> 加入QQ群一起来学习微信运营吧！
		<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=e9b59fe48aeda46685218ccacf87b68a5fda3e0c83c2cfbfac0f6987315ed5d0"><img border="0" src="//pub.idqqimg.com/wpa/images/group.png" alt="公众号运营交流" title="公众号运营交流"></a> 
	</div>

<!--
	<div class="alert alert-danger">

		<i class="fa fa-exclamation-triangle"></i> 更新到1.3.5后无法进入公众号管理的解决方法

		<a href="http://we7.bdou.cc/ti.zip" style="color:#428bca;" target="_blank">点我下载</a> 

	</div>

-->
			<div class="text-center">

				<input name="submit" type="submit" value="立即检查新版本" class="btn btn-danger" />

				<input name="rollback" type="button" value="撤回更新" class="btn btn-default" data-toggle="modal" data-target="#rollback-panel" />

				<input type="hidden" name="token" value="{$_W['token']}" />

			</div>

		</div>

	</form>

	{/if}

	<div class="panel we7-panel">

		<div class="panel-heading">

			更新通知

		</div>

		<div class="panel-body we7-padding">

			<ul class="list-unstyled">

			<script type="text/javascript" src="http://www.bdou.cc/api.php?mod=js&bid=10"></script>

			</ul>

		</div>

	</div>

	<div class="panel we7-panel">

		<div class="panel-heading">

			模块更新

		</div>

		<div class="panel-body we7-padding">

			<ul class="list-unstyled">

			<script type="text/javascript" src="http://www.bdou.cc/api.php?mod=js&bid=31"></script>

			</ul>

		</div>

	</div>

</div>

<div class="modal fade" id="upgrade-file" tabindex="-1" role="dialog" aria-hidden="true">

	<div class="modal-dialog we7-modal-dialog">

		<div class="modal-content">

			<div class="modal-header">

				<button type="button" class="close" data-dismiss="modal">

					<span aria-hidden="true">&times;</span>

					<span class="sr-only">Close</span>

				</button>

				<h4 class="modal-title">更新文件</h4>

			</div>

			<div class="modal-body color-dark">

				{loop $upgrade['files'] $line}

				<div><span style="display:inline-block; width:30px;">{if is_file(IA_ROOT . $line)}M{else}A{/if}</span>{$line}</div>

				{/loop}

			</div>

			<div class="modal-footer">

				<button type="button" class="btn btn-primary"  data-dismiss="modal">确定</button>

			</div>

		</div>

	</div>

</div>

<div class="modal fade" id="upgrade-databases" tabindex="-1" role="dialog" aria-hidden="true">

	<div class="modal-dialog we7-modal-dialog">

		<div class="modal-content">

			<div class="modal-header">

				<button type="button" class="close" data-dismiss="modal">

					<span aria-hidden="true">&times;</span>

					<span class="sr-only">Close</span>

				</button>

				<h4 class="modal-title">更新数据库</h4>

			</div>

			<div class="modal-body color-dark">

				{loop $upgrade['database'] $line}

				<div class="row">

					<div class="col-sm-2">表名:</div>

					<div class="col-sm-4">{$line['tablename']}</div>

					{if !empty($line['new'])}

					<div class="col-sm-6">New</div>

					{else}

					<div class="col-sm-6">{if !empty($line['fields'])}fields: {$line['fields']}; {/if}{if !empty($line['indexes'])}indexes: {$line['indexes']}{/if}</div>

					{/if}

				</div>

				{/loop}

			</div>

			<div class="modal-footer">

				<button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>

			</div>

		</div>

	</div>

</div>



<div class="modal fade" id="upgrade-scripts" tabindex="-1" role="dialog" aria-hidden="true">

	<div class="modal-dialog we7-modal-dialog">

		<div class="modal-content">

			<div class="modal-header">

				<button type="button" class="close" data-dismiss="modal">

					<span aria-hidden="true">&times;</span>

					<span class="sr-only">Close</span>

				</button>

				<h4 class="modal-title">更新脚本</h4>

			</div>

			<div class="modal-body color-dark">

				{loop $upgrade['scripts'] $line}

				<div><span style="display:inline-block; width:100px;">{$line['release']}</span>{$line['message']}</div>

				{/loop}

			</div>

			<div class="modal-footer">

				<button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>

			</div>

		</div>

	</div>

</div>

<div class="modal fade" id="rollback-panel" tabindex="-1" role="dialog" aria-labelledby="rollback-label">

	<div class="modal-dialog">

		<div class="modal-content">

			<div class="modal-header">

				<h4 class="modal-title">更新回滚列表</h4>

			</div>

			<div class="modal-body">

				<div class="alert alert-danger">

					如果要恢复更早的记录请直接查看 <b>/data/patch/</b> 目录

				</div>

				<div class="alert alert-success">

					恢复时，请手动将此目录中的文件上传至网站即可（选中全部文件和目录直接上传）

				</div>

				{if !empty($patchs)}

				<table class="table">

					<tr>

						<th style="width: 200px">日期</th>

						<th >路径</th>

					</tr>

					{loop $patchs $path}

					<tr>

						<td>{php echo date('Y-m-d')} {php echo substr($path, 0, 2)}:{php echo substr($path, 2, 2)}</td>

						<td>{$path}</td>

					</tr>

					{/loop}

				</table>

				{else}

				今天暂无更新

				{/if}

			</div>

		</div>

	</div>

</div>

{if !empty($upgrade) && !empty($upgrade['upgrade'])}

<script type="text/javascript">

	$('#forward').click(function(){

		var a = $("#agreement_0").is(':checked');

		var b = $("#agreement_1").is(':checked');

		var c = $("#agreement_2").is(':checked');

		if(a && b && c) {

			if(confirm('更新将直接覆盖本地文件, 请注意备份文件和数据. \n\n**另注意** 更新过程中不要关闭此浏览器窗口.')) {

				location.href = '{url "cloud/process"}';

			}

		} else {

			util.message("抱歉，更新前请仔细阅读更新协议！", '', 'error');

			return false;

		}

	});

</script>

{/if}

{template 'common/footer'}

